(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/script/PipeGroup.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, '0ded0NSMndArq7v+wMD3Ay5', 'PipeGroup', __filename);
// script/PipeGroup.js

"use strict";

cc.Class({
    extends: cc.Component,

    properties: {
        //上方管子最小高度
        topPipeMinHeight: 100,
        //下方管子最小高度
        bottomPipeMinHeight: 100,
        //上下管子垂直间最小值
        sapcingMinValue: 250,
        //上下管子垂直间最大值
        spacingMaxValue: 300,
        topPipe: cc.Node,
        bottomPipe: cc.Node

    },

    init: function init(pipeManager) {
        this.pipeManager = pipeManager;
        this.initPositionX();
        this.initPositionY();
    },
    initPositionX: function initPositionX() {
        var visibleSize = cc.director.getVisibleSize();
        var sceneLeft = -visibleSize.width / 2;
        var sceneRight = visibleSize.width / 2;
        this.node.x = sceneRight + 300;
        this.recycleX = sceneLeft - Math.max(this.topPipe.width, this.bottomPipe.width);
    },
    initPositionY: function initPositionY() {
        var visivleSize = cc.director.getVisibleSize();
        var topPipeMaxY = visivleSize.height / 2 - this.topPipeMinHeight;
        var bottomPipeMiny = cc.find("Canvas/ground").y + this.bottomPipeMinHeight;
        var spacing = this.sapcingMinValue + Math.random() * (this.spacingMaxValue - this.sapcingMinValue);
        this.topPipe.y = topPipeMaxY - Math.random() * (topPipeMaxY - bottomPipeMiny - spacing);
        this.bottomPipe.y = this.topPipe.y - spacing - 100;
    },


    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start: function start() {},
    update: function update(dt) {
        if (!this.pipeManager.isRunning) {
            return;
        }
        this.node.x += this.pipeManager.pipeMoveSpeed * dt;
        if (this.node.x < this.recycleX) {
            this.pipeManager.recyclePipe(this);
        }
    }
});

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=PipeGroup.js.map
        